import { Component } from "react"

export default class Com1_shouldUpdate extends Component {
  constructor(props) {
    super(props)
  }
  // 子组件是否需要更新，需要用这个api来计算props是否更改
  shouldComponentUpdate(nextProps, nextState, nextContext) {
    if (nextProps.n !== this.props.n) {
      console.log(nextProps, this.props)
    }
    return nextProps.n !== this.props.n
  }

  render() {
    console.log("Com1_shouldUpdate 组件更新")
    return <p>HandleShouldUpdate的n值: {this.props.n}</p>
  }
}
